Skip to content

Stop mise-install from clobbering a user's own wrapper - #13243

Open
Raj-Jagadeesh-A-P wants to merge 2 commits into
omacom:quattrofrom
Raj-Jagadeesh-A-P:fix/issue-7101
Open

Raj-Jagadeesh-A-P wants to merge 2 commits into
omacom:quattrofrom
Raj-Jagadeesh-A-P:fix/issue-7101

Conversation

@Raj-Jagadeesh-A-P

Copy link
Copy Markdown
Contributor

Fixes #7101.

omarchy-mise-install removed ~/.local/bin/ unconditionally before writing its shim. For a user's own wrapper at the same path — pinning a version, or pointing the tool at a custom API base URL — that silently destroyed their setup on every update/migration.

It now refuses to touch anything that is not a mise wrapper:

Copilot AI lite review requested due to automatic review settings September 25, 2026 15:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The guard matched a file on any one line a generated wrapper carries, so a user's own wrapper ending in `exec "/path/to/tool" "$@"` or `exec mise x tool@1.2 -- tool "$@"` was still replaced. It now rebuilds each form the script has ever written from the package the file names and the bin being installed, and requires the whole file to equal one of them, so an extra argument, a redirect, another command or a retargeted binary marks it as the user's. The package is taken from the file rather than the call because callers do switch a command's package (grok moved from npm to mise's own); the bin no caller has ever changed.

Refusing with exit 1 also stopped omarchy-migrate: migrations run under `bash -e` and omarchy-migrate stops at the first failure, so a migration installing a command the user already has would have stalled every migration after it on every update. Leaving the user's file is the intended outcome, so it now exits 0 with a note on stderr. A directory in the way still fails, since it leaves no command at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and run on a disposable Omarchy VM. The bug in #7101 is real: on quattro, omarchy-mise-install claude replaces a user's own ~/.local/bin/claude wrapper. This branch fixes that for the wrapper in the issue, and I pushed one commit on top (ec125cd) for two problems that were still open:

  • Some user wrappers were still replaced. The guard took any file with a single line resembling a generated one as ours, so exec "/opt/claude/bin/claude" "$@" or exec mise x claude@2.0.1 -- claude "$@" was still deleted, even with an export ANTHROPIC_BASE_URL=... above it. It now rebuilds each form the script has ever written, from the package the file names and the bin being installed, and replaces the file only when it matches one of them exactly. An extra argument, a redirect, another command or a different binary leaves it alone. One case can't be detected: a wrapper that pins a version on both lines and changes nothing else is byte-for-byte what the script writes for that package, so it is still regenerated.
  • Refusing would have stalled updates. omarchy-migrate runs each migration under bash -e and stops at the first one that fails. With exit 1, any migration that installs a command the user already has, such as omarchy-mise-install github:basecamp/hey-cli hey, would fail on every update and hold back every migration after it. On the VM, a stand-in migration did exactly that. Leaving the user's file is the intended result, so the script now prints a note to stderr and exits 0. A directory at that path still fails, because then no command is installed.

I also added cases to test/shell.d/mise-install-test.sh: user wrappers are kept, every generated form (including %q-quoted arguments) is regenerated, and a symlink is replaced without touching its target.

What ran on the VM: the new test passes at ec125cd and fails against both quattro and this branch's first commit. All 19 wrappers in install/user/mise.sh regenerate on a second pass. ./test/cli passes. The full shell suite has 5 of 250 files failing: ascii, branding-about-animation, kernel-headers-migration, omarchy-kernel-migration and screenshot-sanity. They fail the same way without this change, and the first four fail on quattro's current tip as well, so none of them come from this branch. CI has not reported on this branch.

Codex (medium effort) gave a second opinion over four rounds. It found the near-match wrappers, the retargeted binary and a directory in the way being reported as success. Each is fixed in the pushed commit, and its last round found nothing further. It may have read this review's own reasoning, so its agreement is not fully independent.

Waiting on the maintainer. The branch forked from an older quattro, and the shell-suite failures above need to be looked at separately.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[Medium risk] Adds safety check to prevent overwriting user wrapper scripts.

The PR is not safe to merge while it can replace a user's pinned wrapper and report a skipped installation as successful.

Findings

  1. P1 Pinned wrappers can be replaced ▶
  2. P1 Skipped installs report success ▶

Summary

The PR adds an ownership check before replacing mise-backed command wrappers and adds tests for user-owned files, historical forms, symlinks, and obstructing directories.

  • A wrapper with a user-pinned package can still be mistaken for an owned wrapper and replaced.
  • A skipped installation reports success, so callers cannot distinguish it from a completed install.

Reviews (1) · Last reviewed commit: "Leave any user wrapper alone, and do it ..."

Comment thread bin/omarchy-mise-install
Comment on lines +42 to +48
named_package=$(sed -n 's/^mise use -g \(--quiet \)\{0,1\}\(.*\)$/\2/p' <<<"$contents")
named_package=${named_package% || exit 1}
exec_line=$(sed -n 's/^exec \(.*\) "\$@"$/\1/p' <<<"$contents")
named_bin=${exec_line#mise x "$named_package" -- }
named_bin=${named_bin#mise exec "$named_package" -- }
[[ $named_package =~ $token ]] || return 1
[[ $named_bin == "\"$bin\"" || $named_bin == "$(printf '%q' "$bin")" ]] || return 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Pinned wrappers can be replaced A user can pin a version by changing the package in a generated wrapper to claude@2.0.1 while keeping its format. This check reads the package from that file but compares only the binary name with the install request. It then treats the wrapper as Omarchy-owned and replaces the user's pinned version with the requested package.

Knowledge Base Used: System updates and migrations

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread bin/omarchy-mise-install
rm -f "$target"
elif [[ -f $target ]]; then
echo "omarchy-mise-install: leaving $target alone, it is not a mise wrapper" >&2
exit 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Skipped installs report success When a user-owned file occupies the command path, this branch leaves it untouched but exits successfully without installing the requested wrapper. A migration that relies on the exit status can then be marked complete even though the install was skipped. The PR description also says this case should exit nonzero.

Suggested change
exit 0
exit 1

Knowledge Base Used: System updates and migrations

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Heads-up: #14539, opened today, fixes the same #7101 bug in omarchy-mise-install. It matches the whole file against every form the generator has written and leaves anything else in place with exit 0, which is where this branch ended up after the follow-up commit. Both PRs edit the same lines, so only one should land. It would be good to compare them and close whichever one is redundant.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy update destroys user binaries in ~/.local/bin at 13 fixed names, including gh and claude

4 participants